<template>
  <div class="service">
    <div class="header">
      <div class="title">物业管理</div>
    </div>
    <marquee behavior="" direction="">
      现本小区已进入装修阶段,进出苑区人员日益增多,管理处为加强小区人员进出管理,确保苑区的安全和谐,须对苑区住户办理业主卡,住户须凭业主卡进出苑区。请业主于近期内到管理处办理,谢谢合作!
    </marquee>
    <div class="block">
      <el-carousel height="230px">
        <el-carousel-item v-for="item in imgList" :key="item">
          <div class="heartnews">{{ item.news }}</div>
          <img :src="item.imgUrl" class="img" />
        </el-carousel-item>
      </el-carousel>
    </div>

    <!-- <el-divider></el-divider> -->
    <div class="phone" :plain="true" @click="openHTML">
      <p><i class="el-icon-phone"></i>联系物业</p>
      <p class="telnumber">
        <a :href="'tel:' + 13826857621">{{ 13826857621 }}</a>
      </p>
    </div>
    <el-collapse accordion>
      <el-collapse-item name="1">
        <template slot="title">
          <i class="el-icon-bank-card"></i>线上缴费
        </template>
        <template>
          <Charge></Charge>
        </template>
      </el-collapse-item>
      <el-collapse-item>
        <template slot="title">
          <i class="el-icon-setting"></i>报事报修
        </template>
        <template>
          <Fix></Fix>
        </template>
      </el-collapse-item>
      <el-collapse-item>
        <template slot="title"> <i class="el-icon-user"></i>智能门禁 </template>
        <template>
          <Access></Access>
        </template>
      </el-collapse-item>
    </el-collapse>
    <div
      class="news"
      v-for="item in newslist"
      :key="item"
      @click="toPage(item.imgsrc, item.newsname)"
    >
      <img :src="item.imgsrc" />
      <div class="newsname">{{ item.newsname }}</div>
      <!-- <p class="telnumber"> 0756-123456</p> -->
    </div>
    <MainTarBar />
  </div>
</template>

<script>
import Charge from "./Charge.vue";
import Fix from "./Fix.vue";
import Access from "./Access.vue";
import MainTarBar from "../components/content/maintarbar/MainTarBar.vue";
import axios from "axios";
export default {
  components: { Charge, Fix, Access, MainTarBar },
  name: "Services",
  mounted() {
    this.add();
  },
  data() {
    return {
      activeNames: ["1"],
      imgList: [
        {
          id: "0001",
          imgUrl: require("./img/pic1.jpeg"),
          news: "怀着一颗宽容的心去生活，再拥挤的世界也会变得无限宽广！",
        },
        {
          id: "0002",
          imgUrl: require("./img/pic2.jpeg"),
          news: "每个人都有自己故事，只是演绎的方式不同。",
        },
        {
          id: "0003",
          imgUrl: require("./img/bg1.jpeg"),
          news: "粽子香香,引来好一切美好。龙舟划划,赶走所有烦恼。",
        },
      ],
      newslist: null,
      imgsrc: "",
    };
  },

  methods: {
    handleChange(val) {
      console.log(val);
    },

    openHTML() {
      this.$message({
        showClose: true,
        dangerouslyUseHTMLString: true,
        message: "<strong>您将拨打 0756-123456</strong>",
      });
    },
    async add() {
      await axios
        .get("http://localhost:8080/data/newslist.json")
        .then((response) => {
          if (response.data.data.success == 200) {
            this.newslist = response.data.data.newslist;
            console.log("111231");
          } else alert("数据获取失败");
        });
    },
    toPage(img, name) {
      this.imgsrc = img;
      this.$router.push({
        path: "/news",
        query: {
          imgsrc: this.imgsrc,
          name: name,
        },
      });
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.phone {
  height: 50px;
  width: 375px;
  margin-top: 8px;
  margin-left: 8px;
  background-color: #f7f7f7;
  /* box-shadow: 1px 1px 5px rgba(193, 196, 190, 0.961); */
  border-radius: 10px;
  display: flex;
}
.phone p {
  font-size: 15px;
  margin-left: 45px;
}
.phone i {
  font-size: 20px;
  color: #41b883;
}
.telnumber {
  color: rgb(77, 76, 76);
}
.header {
  /* background-image: url('./img/bg4.jpeg');  */
  background-color: #41b883;
  height: 70px;
  width: 375px;
  background-size: 100% 100%;
  border-radius: 10px 10px 0 0;
  display: flex;
}
.title {
  height: 20px;
  width: 100px;
  color: rgb(237, 242, 231);
  font-weight: bold;
  text-align: center;
  margin: auto;
  font-size: 17px;
}
.heartnews {
  color: #5e8b7e;
  font-size: 12px;
  opacity: 0.75;
  text-align: center;
  font-weight: bold;
  background-color: #f7f7f7;
  height: 20px;
  line-height: 20px;
  /* padding-top:10px; */
}

.el-carousel__item {
  margin-top: 5px;
  padding-left: 8px;
  border-radius: 10px;
}
.block {
  margin-top: 10px;
  background-color: #f7f7f7;
  box-shadow: 1px 1px 5px rgba(193, 196, 190, 0.961);
  border-radius: 10px;
  height: 220px;
}
.img {
  height: 196px;
  width: 360px;
}
.el-collapse-item >>> .el-collapse-item__header {
  background-color: #f7f7f7;
  border-radius: 5px;
  margin-top: 8px;
  margin-bottom: 8px;
  padding-left:5px;
}
i {
  margin-right: 10px;
  margin-left: 10px;
  margin-top: -2px;
}
.el-icon-bank-card {
  color: rgb(247, 217, 23);
}
.el-icon-setting {
  color: #49a765;
}
.el-icon-user {
  color: blue;
}
.news {
  height: 200px;
  width: 360px;
  margin-top: 8px;
  background-color: #f7f7f7;
  box-shadow: 1px 1px 5px rgba(193, 196, 190, 0.961);
  border-radius: 5px;
  text-align: center;
}
.news img {
  height: 170px;
  width: 360px;
  border-radius: 5px;
}
.newsname {
  font-size: 14px;
  color: rgb(99, 98, 98);
}
a {
  text-decoration: none;
  color: rgb(99, 98, 98);
}

marquee{
  margin-top: 10px;
  font-size: 13px;
  padding: 10px 5px;
  /* background-color: #FFFFBB; */
  color: rgb(57, 55, 55);
  background: #c6ffdd;  /* fallback for old browsers */      background: -webkit-linear-gradient(to right, rgb(198, 255, 221), rgb(251, 215, 134), rgb(247, 121, 125));  /* Chrome 10-25, Safari 5.1-6 */      background: linear-gradient(to right, rgb(198, 255, 221), rgb(251, 215, 134), rgb(247, 121, 125)); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */      
}
</style>
